from constants import *

#used like 'structure' for storing values. source_file and index properties are used in filtration.
class question:
    def __init__(self, head, answers, difficult_level, correct_answer_index, source_file, index):
        self.head = head
        self.answers = list(answers)
        self.difficult_level = int(difficult_level)
        if self.difficult_level < MIN_DIFFICULTY:
            self.difficult_level = MIN_DIFFICULTY
        elif self.difficult_level > MAX_DIFFICULTY:
            self.difficult_level = MAX_DIFFICULTY
        self.correct_answer_index = int(correct_answer_index)
        self.source_file = source_file
        self.index = index
    def __str__(self):
        answers_txt = ''
        for answer in self.answers:
            answers_txt = answers_txt + '\n* ' + answer
        difficult = ''
        if (SHOW_DIFFICULTIES):
            difficult = '(' + str(self.difficult_level) + ')'
        return "====" + self.head + difficult + '====\n' + answers_txt 
    def __repr__(self):
        return 'question(' + self.head + ', ' + 'list(' + self.answers + '), ' + str(self.difficult_level) + \
               ', ' + str(self.correct_answer_index) + ', ' + self.source_file + ', ' + self.index + ')'
    def __eq__(self, other):
        return self.head == other.head and self.difficult_level == other.difficult_level and \
               self.correct_answer_index == other.correct_answer_index
